package cn.edu.nyist.service.impl;

import cn.edu.nyist.entity.Region;
import cn.edu.nyist.entity.RentHouse;
import cn.edu.nyist.mapper.RentHouseMapper;
import cn.edu.nyist.service.RentHouseService;
import cn.edu.nyist.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (RentHouse)表服务实现类
 *
 * @author makejava
 * @since 2021-03-21 17:54:46
 */
@Service("rentHouseService")
public class RentHouseServiceImpl implements RentHouseService {

    @Autowired
    private RentHouseMapper rentHouseMapper;


    @Override
    public PageBean<RentHouse> queryPage(Map<String, Object> paramMap) {
        PageBean<RentHouse> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<RentHouse> datas = rentHouseMapper.queryList(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = rentHouseMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public PageBean<RentHouse> queryPageBelongUser(Map<String, Object> paramMap) {
        PageBean<RentHouse> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<RentHouse> datas = rentHouseMapper.queryListBelongUser(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = rentHouseMapper.queryCountBelongUser(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public int insertRentHouse(RentHouse rentHouse) {
        return rentHouseMapper.insertRentHouse(rentHouse);
    }

    @Override
    public RentHouse selectById(Integer id) {
        return rentHouseMapper.selectById(id);
    }

    @Override
    public int delByRentHouseIds(List<Integer> ids) {
        return rentHouseMapper.delByRentHouseIds(ids);
    }

    @Override
    public int editByRentHouse(RentHouse rentHouse) {
        return rentHouseMapper.editByRentHouse(rentHouse);
    }

    @Override
    public RentHouse selectByRegion(String region) {
        return rentHouseMapper.selectByRegion(region);
    }
}